(function ($,window,document) {

var oTable = {
	init: function () {
		this.doms = $('.com-table');

		for (var i = 0; i < this.doms.length; i++) {
			var oItem = $(this.doms[i]);
			this.initState(oItem);
			this.initEvent(oItem);
		}
	},
	initState: function (dom) {
		this.setScrollStyle(dom);
	},
	initEvent: function (dom) {
		var _this = this;
		// 尺寸变化
		onelresize(dom.find('.com-table-body')[0], function () {
			_this.setScrollStyle(dom);
		})
		onelresize(dom.find('.com-table-body .table-box')[0], function () {
			_this.setScrollStyle(dom);
		})
	},
	// 根据当前是否有显示滚动条，设置thead/tbody的padding-right
	setScrollStyle: function (dom) {
		var oThead = dom.find('.com-table-head'),
			oTbody = dom.find('.com-table-body'),
			oTableBox = oTbody.find('.table-box');
		oThead.css('padding-right', oTbody.height() > oTableBox.height() ? 0 : 10);
	}

}

$(function () {
	oTable.init();
})

})($,window,document);